package com.cqs.leetcode;

import java.util.Arrays;
import java.util.Random;
import java.util.stream.Collectors;

/**
 * @author lixiaowen
 * @create 2019-12-16
 */
public class TestCaseUtils {
    private static final Random random = new Random();

    public static int[] randomArr(int n, int ... range){
        int[] result = new int[n];
        int range2 = n;
        if (range != null && range.length > 0){
            range2 = range[0];
        }
        for (int i = 0; i < n; i++) {
            result[i] = random.nextInt(range2);
        }
        return result;
    }

    public static int[] randomSortedArr(int n, int ... range){
        int[] result = randomArr(n,range);
        Arrays.sort(result);
        return result;
    }

    public static void print(int[] arr){
        if (arr == null || arr.length <= 0) return;
        System.out.println(Arrays.stream(arr).boxed().collect(Collectors.toList()));
    }

    public static String arrFormat(int[] arr){
        if (arr == null || arr.length <= 0) return "";
        return Arrays.stream(arr).boxed().collect(Collectors.toList()).toString();
    }

    public static String arrFormat(boolean[] arr){
        if (arr == null || arr.length <= 0) return "";
        return Arrays.toString(arr);
    }

}
